package top.infopub.mgr.sts.service.impl;

import java.util.Date;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.google.common.collect.Maps;

import top.infopub.generic.GenericDao;
import top.infopub.generic.GenericServiceImpl;
import top.infopub.mgr.sts.dao.ArCollectDao;
import top.infopub.model.sts.ArCollect;
import top.infopub.mgr.sts.service.ArCollectService;

@Service
public class ArCollectServiceImpl extends GenericServiceImpl<ArCollect, String> implements
		ArCollectService {

	@Autowired
	private ArCollectDao arCollectDao;
	
	@Override
	public GenericDao<ArCollect, String> getDao() {
		return arCollectDao;
	}

    @Override
    public Page<ArCollect> selectDataByWhere(Date monthDate, String type, String orgId,
                                             String proName, Page<ArCollect> page) {
        PageHelper.startPage(page.getPageNum(), page.getPageSize());
        Map<String, Object> where = Maps.newHashMap();
        where.put("stsMonth", monthDate);
        if(type.equals("2")){//区域公司
            where.put("hrOrgAreaId", orgId);
        }else if(type.equals("3")){//项目公司
            where.put("hrOrgProId", orgId);
        }
        where.put("proName", proName);
        return (Page<ArCollect>)arCollectDao.selectDataByWhere(where);
    }

}